Cloud architectures are used in cloud computing and cloud storage systems (referred to as cloud systems) for offering function-as-a-service (FaaS) cloud services. Such cloud systems can refer to any type of cloud system such as a private cloud system, public cloud system, or hybrid cloud system. A FaaS cloud service is a type of cloud service that provides a platform to develop, run, and manage application functions on the infrastructure provided by a cloud system. For example, the cloud system can provide computing resources (e.g., servers, hosts, virtual computing instances (VCIs) such as virtual machines (VMs) running on hosts, etc.) as well as storage resources (e.g., networked storage, storage coupled to physical devices, a virtual storage area network, etc.) for executing the functions. Storage resources in a cloud system may include a cloud-based object store or database.
An application function, or function as referred to herein, refers to a piece of code that can be executed using resources of the cloud system. For example, a function may be code that takes an input and provides an output. The execution of the function on the resources of the cloud system allows the function to be developed and launched without the complexity of managing the resources needed to support the execution of the function. Instead, the cloud system provides and maintains such resources, including compute resources and storage resources for executing the function.
Beneficially, FaaS cloud services provided by a cloud system allow developers to scale the execution of application functions more easily than with traditional computing models. For example, typically a monolithic application may include code for executing several functions. In order to scale the use of the monolithic application, many instances of the monolithic application may need to be executed and physical architecture such as servers provided to support such execution. However, using FaaS cloud services, a developer can split the monolithic application into a number of functions. Such functions can be executed independently of one another. Further, execution of each of these functions can be scaled automatically and independently in the cloud system. For example, more of the resources of the cloud system can be provided to execute functions as needed.
Cloud systems can include multiple data centers. A data center includes a plurality of physical computing devices (e.g., servers, hosts, hosts running VCIs, etc.) that are interconnected utilizing physical networking equipment (e.g., physical routers, physical switches, etc.) over a local network. A data center may further include storage (e.g., coupled to one or more of the physical computing devices). The multiple data centers may further be interconnected via a network (e.g., the Internet). Typically, data centers of a cloud system are located in different physical regions. For example, a cloud system may have data centers located in different countries or in different regions of a country (e.g., East United States, West United States, etc.). Some data centers can provide both compute resources and storage resources to users of the cloud system. Some data centers can provide only compute resources to users of the cloud system. Some data centers can provide only storage resources to users of the cloud system.
A developer can load/deploy a function into a cloud system. For example, the cloud system can provide application programming interfaces (APIs) that a developer accesses (e.g., using a web browser running on a computing device) to load functions into the cloud system, such as over a network. The function may be loaded into a data center specified by the developer. In particular, the developer may have to manually choose which data center of the cloud system to load the function into. Further, within the data center, the function may be loaded onto one or more of the compute resources in the data center. Accordingly, the function is executable by one or more compute resources of the data center.
The function can be called/triggered to execute based on a variety of different triggers. For example, the function can be triggered by an application running on a client device (e.g., a computing device such as a mobile device, workstation, server, etc.), another function running in the same data center of the cloud system, a different data center of the cloud system, or another cloud system, another service operating in the cloud system, an event occurring in the cloud system (e.g., a timer expiring, a file being uploaded to storage of the cloud system, etc.), etc.
In one example, the data center into which the function is loaded includes an API gateway that can trigger execution of the function. The API gateway corresponds to one or more computing resources of the data center accessible over a network, such as the Internet. The API gateway may be associated with a uniform resource locator (URL). An application running on a client device can establish an HTTP session (e.g., using an underlying transport layer such as TCP) with the API gateway over the network based on the URL of the API gateway. The application can then exchange HTTP requests and HTTP responses with the API gateway to trigger execution of the function. Though certain aspects are described with respect to establishing an HTTP session and utilizing HTTP requests and HTTP responses, it should be noted that similarly an HTTPS session can be established and HTTPS requests and HTTPS responses utilized. For example, an HTTP request to execute the function can be generated by the application and sent to the API gateway over the established HTTP session. The HTTP request includes information indicative of a request to execute the function. The HTTP request can further include input parameters (e.g., variables, strings, etc.) to be passed to the function as input for execution.
The API gateway receives the HTTP request, and then further selects a computing resource of the data center that includes a copy of the function to handle the request (e.g., based on a load balancing function). Accordingly, the computing resource receives the request and executes the function based on the request from the client. The executed function may return information to the application (e.g., in a HTTP response sent over the internet to the application), read/write data in storage, trigger execution of another function, etc.
Each data center of a cloud system has its own API gateway associated with its own URL. Accordingly, for an application to establish an HTTP session and generate an HTTP request to execute a function, the application is hardcoded with the URL of the desired API gateway to handle the request, and accordingly, hardcoded with the data center used to execute the function.
Similarly, in another example, a function running in the cloud system can trigger another function. For example, the cloud system can provide in its APIs for developing a function, the ability to call another function. For a function to call another function, it has to specify which data center the other function is located in, and accordingly, is hardcoded with the data center used to execute the other function. For example, the function may call another function by establishing an HTTP session with and sending an HTTP request to the API gateway of the data center including the function as discussed.
Further, if a function utilizes persistent storage, such as storage resources of the cloud system, the function is hardcoded with the location of the storage, such as an identifier of the data center in which the storage is located.
In order to reduce network latency between code (e.g., a function, application, etc.) triggering execution of a function and the function itself, the code can be hardcoded to execute the function in a data center that is geographically close to the computing device executing the code. Further, to reduce network latency between the function and storage utilized by the function, the function itself can be hardcoded to utilize storage in a data center that is geographically close to the data center executing the function. In particular, the less geographical distance between computing devices, typically the lower the latency of network communication between the devices. For example, if a developer knows that the code that triggers execution of a function is going to run on a computing device located in the western part of the United States, the developer can load the function onto a data center in the western part of the United States. Further, the developer hardcodes in the code a trigger for the function that triggers execution of the function on the data center in the western part of the United States. If the function itself uses persistent storage, the developer can hardcode the function to utilize storage resources of the same data center that executes the function if it has available storage resources, or another data center with storage resources that is geographically close to the data center that executes the function.
However, hardcoding of the data centers for executing functions in code or hardcoding of the data centers providing storage for functions as discussed can reduce flexibility for changing conditions. For example, a computing device executing code that triggers execution of a function can move locations. Further, a cloud system can add new data centers. Accordingly, the closest data center geographically to the code or function may no longer be the same one that is hardcoded. This can negatively impact network latency between the computing device executing the code and the computing device executing the function, or between a computing device executing the function and the storage.